import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { AuthService } from "../../core/auth/auth.service";
import * as _ from 'lodash';
import { UniversalService } from '../../core/util/universal.service';

@Component({
    selector: 'app-welcome',
    templateUrl: './welcome.component.html',
    styleUrls: ['./welcome.component.scss']
})
export class WelcomeComponent implements OnInit {
    private baseUrl = (window as any).environment.apiBaseUrl;

    constructor(private authService: AuthService,
                private universalService: UniversalService,
                private http: HttpClient,
                private router: Router) { }

    ngOnInit() {
        const searchObj = this.authService.getSearch();
        console.log(searchObj);
        if (searchObj.account) {
            this.authService.casLogin(searchObj.account).subscribe(success => {
                if (success) {
                    setTimeout(() => {
                            this.router.navigate(['portal']);
                        }
                    );
                }
            });
        }
    }
}
